<?php
$serv = new Swoole\Server("0.0.0.0", 8090);

//监听连接进入事件
$serv->on('Connect', function ($serv, $fd) {
    Swoole\Coroutine\System::sleep(5);//此处sleep模拟connect比较慢的情况，这种sleep()是不阻塞的
    echo "onConnect", PHP_EOL;
});

//监听数据接收事件
$serv->on('Receive', function ($serv, $fd, $reactor_id, $data) {
    echo "onReceive", PHP_EOL;
//    $serv->send($fd, json_encode($data));
});

//监听连接关闭事件
$serv->on('Close', function ($serv, $fd) {
    echo "Client: Close.\n";
});

//启动服务器
$serv->start();